package com.meusconcursos.dataupdate;

import java.util.List;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

public class SaxDataParser extends BaseDataParser {

	public SaxDataParser(String metadataUrl) {
		super(metadataUrl);
	}

	@Override
	public List<Table> parse() {
		SAXParserFactory factory = SAXParserFactory.newInstance();
		try {
			SAXParser parser = factory.newSAXParser();
			DataHandler metadataHandler = new DataHandler();
			parser.parse(this.getInputStream(), metadataHandler);
			return metadataHandler.getTables();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

}
